//
//  STTVViewController.swift
//  RouterPushProtocol
//
//  Created by Toj on 2/21/22.
//

import UIKit
import HandyJSON
import YYImage
import Kingfisher


// MARK: - 懒加载(属性), 变量, 初始化init
class STTVViewController: STBaseViewController {
    
    private let viewModel = TVViewModel()
    
    private lazy var pageView: STPageViewController = {
        let view = STPageViewController()
        
        var viewStyle = view.viewStyle
        viewStyle.backgroundColor = .navigation
        
        var cellStyle = view.viewStyle.titleStyle.cellStyle
        cellStyle.fillType = .const
        cellStyle.width = CGFloat.dv_width * 0.5
        cellStyle.textFont = UIFont.boldSystemFont(ofSize: 14)
        cellStyle.textColor = "#999999".to_color
        cellStyle.textSelectedColor = .white
        cellStyle.textBackgroundColor = .clear
        
        var lineStyle = view.viewStyle.titleStyle.lineStyle
        lineStyle.color = .white
        lineStyle.fillType = .fill
        
        return view
    }()
    
    deinit {
        print("-->startimes: \(st_className) func: deinit")
    }
}

// MARK: - 生命周期
extension STTVViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setupMakeInitialize()
        setupMakeAddSubviews()
        setupMakeLayoutSubviews()
    }
}

// MARK: - 点击事件/ 通知事件回调
@objc private extension STTVViewController {
    
}

// MARK: - 子类可重写方法/ objc事件
@objc extension STTVViewController {
    
}

// MARK: - Public
extension STTVViewController {
    
}

// MARK: - Private
private extension STTVViewController {
    
}

// MARK: - 初始化设置
private extension STTVViewController {
    
    func setupMakeAddSubviews() {
        
        addChild(pageView)
        view.addSubview(pageView.view)
    }
    
    func setupMakeLayoutSubviews() {
        pageView.view.snp.makeConstraints { make in
            make.top.equalTo(navigationBar.snp.bottom)
            make.left.right.bottom.equalTo(view)
            make.bottom.equalTo(view).inset(CGFloat.tab_barFullHeight)
        }
    }
    
    func setupMakeInitialize() {
        navigationController?.title = "Push/pre-Order VOD"
        view.backgroundColor = .gray
        
        var vcs = [UIViewController]()
        var titles = [String]()
        
        let free = STTVChildViewController()
        free.tabName = "ALL"
        vcs.append(free)
        titles.append(free.tabName)
        
        let order = STTVChildViewController()
        order.tabName = "RESERVATION CONTENT"
        vcs.append(order)
        titles.append(order.tabName)
        
        pageView.titles = titles
        pageView.views = vcs
    }
}
